<div ng-controller="Approval_DetailsC">
    <div class="bg-light lter b-b wrapper-md">
        <h1 class="m-n font-thin h3">审批详情</h1>
    </div>
    <div class="wrapper-md">
        <div class="panel panel-default">
            <div class="table-responsive">
                <form name="form" class="form-validation">
                    <div class="panel panel-default">
                        <div class="panel-heading">
                            <span class="h4">计划单详情</span>
                        </div>
                        <div class="panel-body">
                            <div class="form-group">
                                <label>客户</label>
                                <input type="text" class="form-control" readonly="readonly" value="{{orderdetaildata.Customer.Name}}">
                            </div>
                            <div class="form-group">
                                <label>公司户头</label>
                                <input type="text" class="form-control" readonly="readonly" value="{{orderdetaildata.Account.Name}}">
                            </div>
                            <div class="form-group">
                                <label>区域</label>
                                <input type="text" class="form-control" readonly="readonly" value="{{orderdetaildata.District.FillName}}">
                            </div>
                            <div class="form-group">
                                <label>具体地址</label>
                                <input type="text" class="form-control" readonly="readonly" value="{{orderdetaildata.Address}}">
                            </div>
                            <!--<div class="form-group">-->
                                <!--<label for="xiankuan" style="margin-right: 10px;">是否先款</label>-->
                                <!--<label class="i-checks">-->
                                    <!--<input type="checkbox" id="xiankuan" disabled="disabled" ng-model="orderdetaildata.IsFullPayment">-->
                                    <!--<i></i>-->
                                <!--</label>-->
                            <!--</div>-->
                            <div class="form-group">
                                <label for="xiankuan" style="margin-right: 10px;">是否先款</label>
                                <label class="i-checks">
                                    <input type="checkbox" id="xiankuan" disabled="disabled" ng-model="orderdetaildata.IsFullPayment">
                                    <i></i>
                                </label>
                                <label for="biaojian" style="margin-right: 10px;">是否标件</label>
                                <label class="i-checks">
                                    <input type="checkbox" id="biaojian" disabled="disabled" ng-model="orderdetaildata.IsStandard">
                                    <i></i>
                                </label>
                                <label for="songhuo" style="margin-right: 10px;">是否送货</label>
                                <label class="i-checks">
                                    <input type="checkbox" id="songhuo" disabled="disabled" ng-model="orderdetaildata.IsDelivery">
                                    <i></i>
                                </label>
                                <label for="songhuo" style="margin-right: 10px;">是否锁价</label>
                                <label class="i-checks">
                                    <input type="checkbox" id="songhuo" disabled="disabled" ng-model="orderdetaildata.IsLockPrice">
                                    <i></i>
                                </label>
                            </div>
                            <!--<div class="form-group">-->
                                <!--<label for="songhuo" style="margin-right: 10px;">是否送货</label>-->
                                <!--<label class="i-checks">-->
                                    <!--<input type="checkbox" id="songhuo" disabled="disabled" ng-model="orderdetaildata.IsDelivery">-->
                                    <!--<i></i>-->
                                <!--</label>-->
                            <!--</div>-->
                            <div class="form-group" ng-if="orderdetaildata.IsDelivery">
                                <label style="margin-right: 10px;">运费是否公户</label>
                                <label class="i-checks">
                                    <input type="checkbox" disabled="disabled" ng-model="orderdetaildata.IsPublicDelivery">
                                    <i></i>
                                </label>
                            </div>
                            <div class="form-group" ng-if="orderdetaildata.IsDelivery">
                                <label>运费合计</label>
                                <input type="text" class="form-control" readonly="readonly" value="{{orderdetaildata.DeliveryPriceTotal}}">
                            </div>
                            <div class="form-group" ng-if="!orderdetaildata.IsDelivery">
                                <label>车辆信息</label>
                                <input type="text" class="form-control" readonly="readonly" value="{{orderdetaildata.VehicleInfos}}">
                            </div>
                            <div class="form-group" ng-if="!orderdetaildata.IsDelivery">
                                <label>联系人</label>
                                <input type="text" class="form-control" readonly="readonly" value="{{orderdetaildata.Contact}}">
                            </div>
                            <div class="form-group" ng-if="!orderdetaildata.IsDelivery">
                                <label>联系人手机号</label>
                                <input type="text" class="form-control" readonly="readonly" value="{{orderdetaildata.ContactPhone}}">
                            </div>
                            <div class="form-group">
                                <label>备注</label>
                                <input type="text" class="form-control" readonly="readonly" value="{{orderdetaildata.Remarks}}">
                            </div>
                            <div class="form-group">
                                <label>仓库</label>
                                <input type="text" class="form-control" readonly="readonly" value="{{orderdetaildata.Provider.Name}}">
                            </div>
                            <div class="form-group">
                                <label>创建人：</label>
                                <span>{{orderdetaildata.Creater.Name}}</span>
                            </div>
                            <div class="form-group">
                                <label>创建时间：</label>
                                <span>{{orderdetaildata.CreateTime}}</span>
                            </div>
                        </div>
                        <div class="container-fluid text-center bg-light lter" >
                            <div class="row">
                                <h3 style="display: inline-block;margin: 0 auto">订单商品列表</h3>
                            </div>
                        </div>
                        <div class="container-fluid" style="padding-top: 10px">
                            <!--<div class="row" style="border-bottom: red solid 1px" ng-repeat="item in orderdetaildata.CommodityInfos">-->
                                <!--<div class="col-xs-12 col-md-12">-->
                                    <!--<div>钢厂：{{item.ProviderCommodity.Commodity.Brand}}</div>-->
                                    <!--<div>名称/材质/规格：{{item.ProviderCommodity.Commodity.Name}}/{{item.ProviderCommodity.Commodity.Standard}}/{{item.ProviderCommodity.Commodity.Format}}</div>-->
                                    <!--<div>单价：{{item.Price | number:2}}/t</div>-->
                                    <!--<div>数量：{{item.Count}}</div>-->
                                    <!--<div>总质量：{{item.Weight | number:3}}t</div>-->
                                    <!--<div>总价：{{item.Price | number:2}}*{{item.Weight | number:3}}t={{item.Price*item.Weight | number:2}}</div>-->
                                <!--</div>-->
                            <!--</div>-->


                            <div class="panel panel-default" ng-repeat="item in orderdetaildata.CommodityInfos" style="margin-bottom: 10px;">
                                <div class="panel-heading">
                                    <div>品牌：{{item.Commodity.Brand}}</div>
                                </div>
                                <div class="panel-body">
                                    <div class="row">
                                        <div class="col-xs-12 col-md-12">
                                            <div>名称/材质/规格：{{item.Commodity.Name}}/{{item.Commodity.Standard}}/{{item.Commodity.Format}}</div>
                                            <div>单价：{{item.Price | number:2}}/t</div>
                                            <div>数量：{{item.Count | number:2}}</div>
                                            <div>总质量：{{item.Weight | number:3}}t</div>
                                        </div>
                                    </div>
                                </div>
                                <div class="panel-footer">
                                    <div>总价：{{item.Price | number:2}}*{{item.Weight | number:3}}t={{item.Price*item.Weight | number:2}}</div>
                                </div>
                            </div>
                            <div class="row text-left container-fluid">
                                <h4 style="display: inline-block">总价：{{orderdetaildata.Total | number:2}}</h4>
                            </div>
                            <div style="padding: 0px 15px">
                                <span><b>流程类型：</b>{{data.TypeName}}</span><br>
                                <span><b>先款和非标优惠合计：</b>{{orderdetaildata.UnitTotal}}</span><br>
                                <label><b>每吨优惠：</b></label>{{orderdetaildata.ApplyDiscount}}/t<br>
                                <span><b>内容：</b>{{data.Title}}</span><br>
                                <span><b>申请人：</b>{{data.Creater.Name}}</span><br>
                                <span><b>审批人：</b>{{data.NowApproverName}}</span><br>
                                <label><b>审批意见:</b></label>{{data.Remarks}}<br>

                                <div ng-if="data.ApprovalState==1||data.ApprovalState==0">
                                    <input ng-disabled="item.ApprovalState==2||item.ApprovalState==3" ng-model="data.opinion" type="text" class="form-control">
                                    <button type="button" class="btn btn-success" ng-click="DoAppr(true)" ng-hide="item.ApprovalState==2||item.ApprovalState==3">通过</button>
                                    <button type="button" class="btn btn-warning" ng-click="DoAppr(false)" ng-hide="item.ApprovalState==2||item.ApprovalState==3">驳回</button>
                                    <button type="button" class="btn btn-default" ng-click="goorderList()">返回列表</button>
                                    <span ng-show="item.ApprovalState==2">已通过</span>
                                    <span ng-show="item.ApprovalState==3">已驳回</span>
                                </div>
                        </div>
                    </div>
                  </div>
                  </form>
                </div>
            </div>
        </div>
    </div>
<script>
    angular.module('app') //非标优惠
        .controller("Approval_DetailsC", function($scope, $state, $http,$stateParams) {
            $http({
                url: "/api/Approval?id=" + $stateParams.id,
                    method: "GET"
                   // data: { id: $stateParams.id}
                })
                .then(function(res) {
                    $scope.data = res.data;
                    console.log($scope.data);
                    //获取计划单详细数据
                    $http({
                        url:"../api/Order/Detail?id="+$scope.data.Tag,
                        method:"GET"
                    })
                            .then(function (res) {
                                $scope.orderdetaildata = res.data;
                                console.log($scope.orderdetaildata);
                            })
                            .then(function (error) {
                                if(error){
                                    console.log("error");
                                }
                            });
                })
                .then(function(error) {
                    if (error) {
                        alert("数据获取失败");
                    }
                });

            //返回列表
            $scope.goorderList = function(){
                $state.go('app.Approval_Index');
            };
            $scope.DoAppr= function(isOk) {
                $http.post("/api/Approval/Approval?id=" + $stateParams.id + "&pass=" + isOk + "&opinion=" + $scope.data.opinion)
                .success(function() {
                        alert("审批完成");
                        $scope.goorderList();
                    }).error(function() {alert("处理失败")})
                ;
            }
    });

</script>